package cn.db101.gocentdaily.model;

import cn.hutool.http.HttpStatus;
import lombok.Data;

/**
 * @author zooy
 * @create 2024-06-02 2:38
 * @description
 */
@Data
public class ResultModel<T> {

    private int code;

    private String message;

    private T data;

    public ResultModel(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static <T> ResultModel success(T data) {

        ResultModel rm = new ResultModel(HttpStatus.HTTP_OK, "success");
        rm.setData(data);
        return rm;
    }

    public static ResultModel success() {

        ResultModel rm = new ResultModel(HttpStatus.HTTP_OK, "success");
        return rm;
    }

    public static ResultModel failed(String message) {

        return new ResultModel(HttpStatus.HTTP_INTERNAL_ERROR, message);
    }

    public static ResultModel failed(int code, String message) {

        return new ResultModel(code, message);
    }


}
